

/*
This do-file reproduces Table 4 of the paper "Dismantling the \Jungle":
Migrant Relocation and Extreme Voting in France", by P. Vertier, M. Viskanic, and M. Gamalerio

N.B. Given that Trendeo data were provided under a confidentiality agreement to one of the authors, 
the geographic identifiers present in this dataset have been randomly shuffled and modified.

*/

log using "Table 4", replace text

clear

use "Table 4 dataset.dta"


*************
***Table 4***
************* 
 
preserve
foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period>=2
keep if log_fn!=.
count

foreach var of varlist  tx_creationette_2    {
 
 
  ***Add control variables + FE***   
 
reg `var'  CAO_period_3 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 4", ///
keep(CAO_period_3) ctitle(`var', controls, time FE, municipal FE) bdec(3) nocons excel tex `append'
  
 
 
 }
 ***  
  restore  
 count  
  

 
 reg log_fn  CAO_period_3 tx_creationette_2 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_, cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 4", ///
keep(CAO_period_3 tx_creationette_2) ctitle(log_fn, controls, time FE, municipal FE) bdec(3) nocons excel tex `append'
 
 
 
preserve 

keep if period==3


foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {


drop if `var'==.

}
***
 
  foreach var of varlist  tx_creationette_post_new  {
  
  
 ivreg2  `var' (CAO= num_group_vv)   coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep) first

qui outreg2 using "Table 4", ///
keep(CAO) ctitle(IV, `var', all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'
  
  
  
  }
****

 ivreg2  evol2_fn_2012_2017 (CAO= num_group_vv)  tx_creationette_post_new   coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep) first

qui outreg2 using "Table 4", ///
keep(CAO tx_creationette_post_new) ctitle(IV, , all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'

 
 restore
 
 log close
 